<?php 
$user=$session->read('User');
$companyid=$session->read("companyid");
$isflag=$action->checkPermissions($user,$companyid);
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
    	<h2>
		<?php 
		$companyname=$session->read("companyname");
		$companyid=$session->read("companyid");
		echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
		?>
    	</h2>
    	<div class='clear'></div>
    </div>
    <div class="right item_add_btn">
		<?php
			$cuser=$session->read('User'); 
			if($form->value('Achievement.id')){
			$str_title=__("Edit",true);
			}else{
			$str_title=__("Add",true);
			}
    		echo $html->link(__("Cancel",true).$str_title,"/companys/achievements/");
    	?>
	</div>
    <div class="clear"></div>
</div>

<?php
echo $form->create('Company', array('url' => "/companys/editachievement",'id'=>'patentform','enctype'=>'multipart/form-data','onsubmit'=>"return checkainfo()"));
?>
 <?php 
        	$radiovalue=array("1"=>"是","0"=>"否");
         	$attributes=array('legend'=>false);
        ?>
<div class="right_side_scollbar">
<div class="detail_info_panel">
<div class="details_item_line">
	<div class="details_item">
		<div class="form_left_title left"><font style="color:red">*</font>合作高校：</div>
		<div class="form_right_e_input left"><?php echo $form->text('Achievement.universty_rely',array('maxlength'=>'100'));?></div>
		<div id='unrely' style='display:none;' class="error_message">请输入合作高校</div>
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "是否签约" ;?>：</div>
	    <div class="form_right_e_input left"><?php echo $form->radio('Achievement.is_rely',$radiovalue,array('legend'=>false));?></div>
	</div>
</div> 
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "签约日期" ;?>：</div>
	    <?php if($form->value('Achievement.a_time')){ ?>
	    <div class="form_right_e_input form_date_picker left"><?php echo $form->text('Achievement.a_time',array("maxlength"=>"10","style"=>"width:130px","value"=> date("Y-m-d",strtotime($form->value('Achievement.a_time'))),"onfocus"=>"WdatePicker()"));?></div>
	    <?php }else{ ?>
	    <div class="form_right_e_input form_date_picker left"><?php echo $form->text('Achievement.a_time',array("maxlength"=>"10","onfocus"=>"WdatePicker()","style"=>"width:130px"));?></div>
	    <?php } ?>
	    <div id='achtimemessage' style='display:none;' class="error_message">请选择签约日期</div>
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><font style="color:red">*</font><?php echo "合同金额" ;?>：</div>
	    <div class="form_right_e_input left">
	    <?php echo $form->text('Achievement.cost',array("placeholder"=>"0.00","onkeydown"=>"checkpricekeyup(this,event)","style"=>"width:80px"));?>￥ 
	    </div>
	    <div id='achcostmessage' style='display:none;' class="error_message">请填写合同金额</div>
	</div>
</div>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php echo "合作进度" ;?>：</div>
	    <div class="form_right_e_input left"><?php echo $form->text('Achievement.remark',array('maxlength'=>'100'));?></div>	    
	</div>
</div>
<?php 
//	$universitydisplay="none";
//	$isrely=$form->value('Achievement.is_rely');
//	if($isrely){
//		$universitydisplay="block";
//	}
?>
<!--<div class="details_item_line" id="universty_rely" style="display:<?php //echo $universitydisplay ?>">
	<div class="details_item">
		<div class="form_left_title left">高校名称：</div>
		<div class="form_right_e_input left"><?php //echo $form->text('Achievement.universty_rely',array('maxlength'=>'100'));?></div>
		<div id='unrely' style='display:none;' class="error_message">请输入高校名称</div>
	</div>
</div>
	       
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"><?php //echo "备注" ;?>：</div>
	    <div class="form_right_e_input left"><?php //echo $form->textarea('Achievement.remark');?></div>	    
	</div>
</div>
-->
<div class="details_item_line">
	<div class="details_item">
	   <div class="form_left_title left"><?php echo "附件";?>：</div>
	    <div class="form_right_input left">
	    <?php if($attachments){?>
        	<div class="file_category_list">
        		<div id="filelist0" class="file_lists">
        			<ul>
	                	<?php
	                	$dan="'";
	                	foreach($attachments as $attachment) {
								echo "<li>";
								echo "<span>".$html->link($attachment["file_name"],'/projects/download/'.$attachment["id"],null)."</span>";
								echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
								if($isflag){
									echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
								}
								echo "</li>";
						}
	                	?>
	                </ul>
                </div>
            </div>
	    <?php }?>
		    <div id="add1" class="left text_box"> 
				<div class="file_add_box">
					<input type="file" id="upload[]" name="upload[]" />
				</div>
			</div>
			<div class="clear"></div>
			<div id="add2" class="left filelist"></div>
			<div class="left clear">
				<div class="left add_sub_file_btn">
					<span onclick="add()" href="#"><?php echo $html->image('list-add.png')?></span>&nbsp;
					<span onclick="remove()" href="#"><?php echo $html->image('list-remove.png')?></span>
				</div>
			</div>
	 	</div>
	</div>
</div>

<?php
echo $form->hidden('Achievement.owner',array('value' => $cuser['id'])) ; 
echo $form->hidden('Achievement.cid',array('value' => $companyid)) ;
echo $form->hidden('Achievement.id') ;
?>
<div class="details_item_line">
	<div class="details_item">
	    <div class="form_left_title left"></div>
		<div class="form_add_submit left">
	   		 <?php echo $form->submit(__('Save',true), array("id"=>"adduser","name"=>"submit","class"=>"buttom","div"=>false));  ?>
	    </div>
	</div>
</div>
</div>
</div>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>
<script>
//if(!$("#AchievementId").val()){
//$(document).ready(function() {	
//  $("#uniform-AchievementCostType0").children().addClass("checked");
//  });
//}
//function setuniversty_rely(obj)
//{
//	var isflag=obj.value;
//	if(isflag=="1"){
//		$("#universty_rely").attr("style","display:block");
//	}else{
//		$("#universty_rely").attr("style","display:none");
//	}
//}
function checkainfo(){
	var achievementrely=$("#AchievementUniverstyRely").val();
	var isReply1=$('#AchievementIsRely1').attr("checked");
	if(achievementrely.trim() == ''){
		$("#unrely").css('display','block');
		return false;
	}else{
		$("#unrely").css('display','none');
	}
	if(isReply1){
	  	if($("#AchievementATime").val().trim() == ''){
			$("#achtimemessage").css('display','block');
			return false;
	  	}else{
	 	 	$("#achtimemessage").css('display','none');
	  	}
	}else{
		$("#achtimemessage").css('display','none');
	}
  	if($("#AchievementCost").val().trim() == ''){
		$("#achcostmessage").css('display','block');
		return false;
  	}else{
	 	$("#achcostmessage").css('display','none');
	} 
}
</script>